<?
include("common/header.html");
include("common/left.html");
include("class/OrderRecord.php");
include("class/ProOrder.php");
include("class/SoapInit.class.php");
$memberID=$_SESSION['sid'];
$ac=$GLOBALS['_ac'];
$pw=$GLOBALS['_pw'];
$s = SoapInit::GetSoapInside();//print_r($_SESSION);
$ordernum = $_REQUEST['ordernum'];
if(!$ordernum || $ordernum=='')
    exit('没有输入有效的订单号');
$or =new OrderRecord($ordernum,$s);
$mporder=new ProOrder($memberID,$s);
$ifpack = 1;
$concat_id = 0;


//TODO::复票订单（联票）
// if (isset($_GET['pack']) && $_GET['pack']==1 && $_GET['type']!='F') {
    // $ifpack = 0;
    // $concat_id = 1;
// }
// $orderInfo=$or->info($ifpack, $concat_id);
if($_SESSION['sid'] !=1){
    if($_GET['from']=='buy') $buyid = $_SESSION['sid'];
    if($_GET['from']=='sale') $saleid = $_SESSION['sid'];
}else{//管理员查看时 需要借助额外的 mid的 仿造身份查看订单的价钱
    $saleid = $_GET['aid']!=1?$_GET['aid']+0:0;
}

if($_SESSION['dtype'] ==2){
    $str = "select apply_did  from uu_land where  salerid={$_SESSION['saccount']} limit 1";
    $GLOBALS['le']->query($str);
    $GLOBALS['le']->fetch_assoc();
    $buyid = '';
    $saleid = $GLOBALS['le']->f('apply_did');
}
if($_SESSION['sdtype']==3){//合并过的终端并且是主体
    $sql = "select preSalerID from pft_terminal_share where nowSalerID={$_SESSION['saccount']}";
    $GLOBALS['le']->query($sql);
    while($row=$GLOBALS['le']->fetch_assoc()){
        $total_salerid[] = $row['preSalerID'];
    }
}
begin:
if($total_salerid){
    foreach($total_salerid as $v){
        $str = "select apply_did  from uu_land where  salerid=$v limit 1";
        $GLOBALS['le']->query($str);
        $GLOBALS['le']->fetch_assoc();
        $buyid = '';
        $saleid = $GLOBALS['le']->f('apply_did');
        $orderInfo=$or->info_n($buyid,$saleid);
        if($orderInfo['mainOrder'])
        {
            break;
        }else{
            $orderInfo=$or->info_n($saleid,'');
            if($orderInfo['mainOrder']) break;
        }
    }
    if(!$orderInfo['mainOrder']) exit('你无权查看此订单');
}
else
    $orderInfo=$or->info_n($buyid,$saleid);
//
//var_dump((string)$orderInfo['mainOrder']->UUp_type);exit;
if((string)$orderInfo['mainOrder']->UUp_type=='' && $_SESSION['sid']==1 && !$admin_mark){
    $buyid = $saleid;
    $saleid = null;
    $admin_mark=1;
    goto begin;
    //如果是自供自销 只有aid是查不出订单的 需要mid=aid
}else if((string)$orderInfo['mainOrder']->UUp_type=='' && $_SESSION['sid']==1 && $admin_mark){
    exit('订单信息出错');
}



$_GET['type'] = (string)$orderInfo['mainOrder']->UUp_type;


/*
@ 主票只会查出一单 但是套票 联票的子票会查出很多 需要去掉订单号重复的订单
*/
if($_SESSION['sid'] ==1){
    $childOrder_array = array();
	if(count($orderInfo['childOrder'])){
		foreach($orderInfo['childOrder']  as $k => $v){
			if(array_search((int)$v->UUordernum,$childOrder_array)){
				unset($orderInfo['childOrder'][$k]);
				continue;
			}
			$childOrder_array[(int)$v->UUordernum] = (int)$v->UUordernum;
		}
	}
}

$orders = array();
$title_sub = '产品信息';
if ($_GET['type']=='F') {
    $orders = $orderInfo['childOrder'];
    $title_sub = '套票信息';
}
else {

	$orders=array($orderInfo['mainOrder']);
	$orders=array_merge($orders,$orderInfo['childOrder']);

}

$appendInfo=$orderInfo['mainOrder']->UUaids_money;


$sel="select group_id from pft_member where id={$_SESSION ['sid']} limit 1";
$GLOBALS['le']->query($sel);
$GLOBALS['le']->fetch_assoc();
$group_id=$GLOBALS['le']->f('group_id');
if($orderInfo['mainOrder']->UUmid!=$memberID && $_SESSION['dtype']!=9 && $group_id!=4){
    if($orderInfo['mainOrder']->UUstatus!=1){
        $tel = (string)$orderInfo['mainOrder']->UUordertel;
        $orderInfo['mainOrder']->UUordertel=substr_replace($tel,"****",3,4);
    }
}

$totalMoney = 0;

// 处理显示购买人或者销售人
$aids = (string)$orderInfo['mainOrder']->UUaids;
$price = (string)$orderInfo['mainOrder']->UUaids_price;
$lastF = true;
if($aids!=0){// 多级，转分销
    $price_arr = explode(',',$price.','.(string)$orderInfo['mainOrder']->UUtprice);
    $aids_arr = explode(',',$aids.','.(string)$orderInfo['mainOrder']->UUmid);
    $size = count($aids_arr);
    $aids_flip = array_flip($aids_arr);//键值反转
    if( isset($aids_flip[$saleid]) || isset($aids_flip[$buyid]) || $_SESSION['sid']==1){// 如果存在aids，否则最下级
//        $key = $aids_flip[$_SESSION['sid']];
//        if($_SESSION['sid']==1) $key = $aids_flip[$saleid];
        if($_GET['from']=='sale' && $saleid){// 已卖出显示分销商
            $key = $aids_flip[$saleid];
            if($key<($size-1)){
                $did = $aids_arr[$key+1];$lastF = false;
                $orderInfo['mainOrder']->UUtprice = $price_arr[$key];
            }
        }else{// 已买到现在供应商
            $key = $aids_flip[$buyid];
            if($key<$size){
                $did = $aids_arr[$key-1];$lastF = false;
                $orderInfo['mainOrder']->UUtprice = $price_arr[$key-1];
            }
        }
    }
}
//处理联票的子票金额
if(count($orderInfo['childOrder'])){
    foreach($orderInfo['childOrder'] as$k => $row){
        $aids = (string)$row->UUaids;
        $price = '';
        $price = (string)$row->UUaids_price;
        if($aids!=0){// 多级，转分销
            $price .= ','.(string)$row->UUtprice;
            $price_arr = explode(',',$price);
            $aids_arr = explode(',',$aids);
            $size = count($aids_arr);
            $aids_flip = array_flip($aids_arr);//键值反转
            if(isset($aids_flip[$saleid]) || isset($aids_flip[$buyid])|| $_SESSION['sid']==1){// 如果存在aids，否则最下级
//                $key = $aids_flip[$_SESSION['sid']];
//                if($_SESSION['sid']==1) $key = $aids_flip[$saleid];
                if($_REQUEST['from']=='sale'){// 已卖出显示分销商
                    $key = $aids_flip[$saleid];
                    if($key<($size-1)){
                        $did = $aids_arr[$key+1];
                        $orderInfo['childOrder'][$k]->UUtprice = $price_arr[$key];
                    }
                }else{// 已买到现在供应商
                    $key = $aids_flip[$buyid];
                    if($key<$size){
                        $did = $aids_arr[$key-1];
                        $orderInfo['childOrder'][$k]->UUtprice = $price_arr[$key-1];
                    }
                }
            }
        }
    }
}



if($orderInfo['mainOrder']->UUaids){
    // 处理价格
    $_aids=explode(",",(string)$orderInfo['mainOrder']->UUaids);
//    $_aids_price = explode(",",(string)$orderInfo['mainOrder']->UUaids_price);
    // foreach($_aids as $k=>$ct){
        // if($ct==$_SESSION['sid'] && $_REQUEST['from']=='sale'){
            // $orderInfo['mainOrder']->UUtprice=$_aids_price[$k];
            // break;
        // }
    // }
    $dname=array();
    $totalMoney = $orderInfo['mainOrder']->UUtnum * $orderInfo['mainOrder']->UUtprice;
    $mids = $orderInfo['mainOrder']->UUaids.','.$orderInfo['mainOrder']->UUmid.",".$orderInfo['mainOrder']->UUaid;

	$sel="select id,dname from pft_member where id in ($mids)";
    $GLOBALS['le']->query($sel);
    while($row=$GLOBALS['le']->fetch_assoc()){
        $dname[$row['id']]=$row['dname'];
    }
}


if((string)$orderInfo['mainOrder']->UUaids==0){
    $_aids[] = (string)$orderInfo['mainOrder']->UUaid;
}

//订单权限判断
if($_SESSION['sdtype']==2 && $orderInfo['mainOrder']->UUsalerid!=$_SESSION['saccount']){
    goto change_buy_sale;
}

if (
    (($_SESSION['sid']!=1 && $_SESSION['sdtype']!=2
	&& !in_array($memberID, $_aids)
	&& $orderInfo['mainOrder']->UUsellid!=$memberID
	&& $orderInfo['mainOrder']->UUbuyid!=$memberID
	&& $orderInfo['mainOrder']->UUmid != $memberID
    ) || (
        $_SESSION['dtype']==5
		&& $tel!=$_SESSION['account']
    ))&& $_SESSION['dtype']!=3
)
    {
		goto change_buy_sale;
	}
goto gogo;

change_buy_sale:

if($has_change)
    exit('您无权限查看此订单');
$has_change = 1;

$tmp = $buyid;
$buyid = $saleid;
$saleid = $tmp;

goto begin;

gogo:


$ordernums = array();
if(count($orders)>0){
	$t = array();
//	if($_GET['type']=='C') $orders[] = $orderInfo['mainOrder'];
    foreach($orders as $key=> $cur){
        $ordernums[] = (int)$cur->UUordernum;
        if($key==0) continue;
        $totalMoney = $totalMoney+((string)$cur->UUtnum * (string)$cur->UUtprice);
		$t[(int)$cur->UUordernum] = $cur;
    }
    /* 这端代码是干嘛用的 酒店类的信息直接变空了
	if($_GET['type']=='C'){
		$orders = $t;
		arsort($orders);
	}
    */

}

//

if($orderInfo['mainOrder']->UUp_type=='F'){
    $totalMoney = $orderInfo['totalPrice'][0];
}


if($aids==0 || $lastF){
	$did = ($_REQUEST['from']=='sale') ? $orderInfo['mainOrder']->UUmid:$orderInfo['mainOrder']->UUaid;
}
// 获取名称
$sel="select id,dname from pft_member where id='$did' limit 1";
$GLOBALS['le']->query($sel);
$GLOBALS['le']->fetch_assoc();
$dname_one = $GLOBALS['le']->f('dname');




$udata = array();
if($ordernums){
    $sql="select id,orderid,pre_num,done_num,rectime from pft_order_num_modify where orderid in (".implode(',',$ordernums).") order by id asc";
    $GLOBALS['le']->query($sql);
    while($row=$GLOBALS['le']->fetch_assoc()){
        $udata[$row['orderid']] = $row;
    }
}

// 判断是否为路线产品 是的话 取出集合地点
$sel_land_type = 'select l.p_type,l.ass_station from uu_land_f l left join uu_jq_ticket t on l.lid=t.landid where t.id='.
                        (string)$orderInfo['mainOrder']->UUtid.' limit 1';
$GLOBALS['le']->query($sel_land_type);
$GLOBALS['le']->fetch_assoc();
$land_type=$le->f('p_type');

if($land_type == 'B'){
    $ass_station=unserialize($le->f('ass_station'));
    // var_dump($ass_station);
}

//支付方式判断
if(
    (string)$orderInfo['mainOrder']->UUaids!='0' &&  //供销参与人数超过2个
    (int)$orderInfo['mainOrder']->UUbuyid!=(int)$orderInfo['mainOrder']->UUmid && //不是最后一级
    $_SESSION['sid']!=1  //不是管理员
){
    $aid_money = unserialize($orderInfo['mainOrder']->UUaids_money);
    if($buyid!=''){
        foreach($aid_money as $v){
            if($v[0]==$_SESSION['sid']){
                $orderInfo['mainOrder']->UUpmode = $v[1]== 1 ?
                    0//余额
                    :2//授信
                ;

                break;
            }
        }
    }
    else{
        //查找自己在aids中的位置 然后在$aid_money中找自己的下一级在哪里
        $aid_position = (string)$orderInfo['mainOrder']->UUaids;
        $aid_position = explode(',',$aid_position);
        $position = array_search($_SESSION['sid'],$aid_position);
        foreach($aid_money as $v){
            if($v[0]==$aid_position[$position+1]){
                $orderInfo['mainOrder']->UUpmode = $v[1]== 1 ? 0 :2;
                break;
            }
        }
    }
}else{
    $payModeZ = explode('_',(string)$orderInfo['mainOrder']->UUremotenum);
    $payMode = '';
    switch($payModeZ[0]){
        case 'MOBILE':
            $payMode = '手机-';
            break;
        case 'PC':
            $payMode = '电脑-';
            break;
        case 'MO':
            $payMode = '手机-';
            break;
        default:
            break;
    }
    switch($payModeZ[1]){
        case 'ALIPAY':
            $payMode .= '支付宝';
            break;
        case 'ALI':
            $payMode .= '支付宝';
            break;
        case 'WEPAY':
            $payMode .= '微信';
            break;
        case 'UNI':
            $payMode .= '银联';
            break;
        case 'IPS':
            $payMode .= '环迅';
            break;
        default:
            break;
    }
}
$payMode = $payMode == '' ? OrderRecord::$paymodeT[(int)$orderInfo['mainOrder']->UUpmode] :$payMode;


// 演出类信息输出
$additional_h = '';
if($_GET['type']=='H'){
	$series = (string)$orderInfo['mainOrder']->UUseries;
	$series = unserialize($series);
	$arr = explode('，', $series[6]);
	$round = explode('：', $arr[1]);
	$additional_h.= '<tr><th>演出时间：</th>';
	$additional_h.= '<td>'.$series[4].'</td>';
	$additional_h.= '<th>座位分区：</th>';
	$additional_h.= '<td>'.$round[1].'</td>';
	$additional_h.= '<th>座位号：</th>';
	$additional_h.= '<td ><div class="setwidth_a">'.str_replace('_', ',', $series[5]).'</div></td></tr>';
}

// 多身份证显示
if((string)$orderInfo['mainOrder']->UUpersonid!=0){
	$tourists = array();
	$sql = "select idcard,tourist from uu_order_tourist_info where orderid=$ordernum";
	$GLOBALS['le']->query($sql);
	while($row=$GLOBALS['le']->fetch_assoc()) $tourists[$row['idcard']] = $row['tourist'];
}


// 获取门票配置
$tid = (int)$orderInfo['mainOrder']->UUtid;
$sql = "select f.ass_station,t.sourceT,f.sendVoucher from uu_land_f f left join uu_jq_ticket t on f.lid=t.landid where t.id=$tid limit 1";
$GLOBALS['le']->query($sql);
$tinfo = $GLOBALS['le']->fetch_assoc();
if($tinfo['p_type']=='B') $ass_station=unserialize($tinfo['ass_station']);

// 短信发送次数
$sendSmsNumber = (string)$orderInfo['mainOrder']->UUremsg ? $orderInfo['mainOrder']->UUremsg:'非平台发送';


// 凭证码显示及权限判断  只有最末级和最原始供应商有权限 20151009 TongBaoChun 交由林农确认
$voucher  = (string)$orderInfo['mainOrder']->UUcode;
$UUaids_t = explode(',', (string)$orderInfo['mainOrder']->UUaids);
$UUaids_a = array_merge($UUaids_t, array((int)$orderInfo['mainOrder']->UUmid,(int)$orderInfo['mainOrder']->UUaid));
// $UUaids_a = array(current($UUaids_t), (int)$orderInfo['mainOrder']->UUmid);
if((string)$orderInfo['mainOrder']->UUvcode && $tinfo['sourceT']==2) $voucher = (string)$orderInfo['mainOrder']->UUvcode;
if($_SESSION['sdtype']!=9 && !in_array($_SESSION['sid'], $UUaids_a)) $voucher = '无权限查看';



?>
<link type="text/css" rel="stylesheet" href="css/orderView.css" rel="stylesheet" media="screen" />
<link rel="stylesheet" type="text/css" href="css/default.css"/>
<link rel="stylesheet" type="text/css" href="css/page.css"/>
<link rel="stylesheet" type="text/css" href="css/sell_product.css"/>
<style>
table{ width:100%;margin-bottom:30px;word-wrap:break-word;}
th,td{border:1px solid #BCDFFF;line-height:22px;}
caption{font-size:14px; font-weight:bold; border-left:3px solid orange; padding-left:5px; margin-bottom:5px;}
th{background-color: #EEF7FF;padding-right: 3px;text-align: right;width:90px;}
td{text-align:left;padding:5px 5px;width:150px;height:24px;word-break:break-all;}
.red{ color:red};
.green{ color:green}
.setbtn_a{border: 0 none;width: 70px;height: 25px;background: #0797D9;color: #FFF;border-radius:5px;-moz-border-radius:5px;}
.setheight_a{height:25px;}
.setwidth_a{width:150px;word-wrap:break-word;}
.aaBtn{display: inline-block; width: 60px; height: 25px;text-align: center; line-height: 25px; border: 0 none; background: #3DBA3F; color: #FFFFFF; border-radius: 2px; -moz-border-radius: 2px; margin-left: 12px; cursor: pointer; }
.aaBtn:active{background: #5FB037;}
a.aaBtn,a.aaBtn:link,a.aaBtn:visited,a.aaBtn:active,a.aaBtn:hover{color: #FFFFFF; text-decoration: none;}
.recordBtn{display: inline; background: none; border: 0 none; color: #0797D8; margin-left: 5px; cursor: pointer}
</style>
    <div class="right_content">
    <input type="hidden" id="ordernum" value="<?=$orderInfo['mainOrder']->UUordernum?>"/>
    <table>
        <caption>订单信息</caption>
		<?if($_GET['type']=='F'):?>
		<tr>    
            <th>产品名称：</th>
            <td colspan="5"><?=(string)$orderInfo['mainOrder']->UUltitle.(string)$orderInfo['mainOrder']->UUttitle?></td>
        </tr>
		<?endif;?>
        <tr>    
            <th>订单号：</th>
            <td><?=$orderInfo['mainOrder']->UUordernum?>
                <?if((string)$orderInfo['mainOrder']->UUremotenum){?>
                （<?=(string)$orderInfo['mainOrder']->UUremotenum?>）
                <?}?></td>
            <th>订单金额：</th>
            <td><?=$totalMoney/100?></td>
            <th>订单状态：</th>
            <?
            // 支付宝支付但未支付
            if((string)$orderInfo['mainOrder']->UUpmode==1 && (string)$orderInfo['mainOrder']->UUpaystatus==2)
            {?>
            <td><?=OrderRecord::$paystatusT[(string)$orderInfo['mainOrder']->UUpaystatus]?></td>
            <?}else{?>
                <td><?=OrderRecord::$UUstatusT[(string)$orderInfo['mainOrder']->UUstatus]?></td>
            <?}?>
        </tr>
        <tr>    
            <th>下单时间：</th>
            <td><?=$orderInfo['mainOrder']->UUordertime?></td>
            <th>有效期：</th>
            <?if($orderInfo['mainOrder']->UUp_type=='C'):?>
			<td>入住时间：<?=$orderInfo['mainOrder']->UUbegintime?><br/>离店时间：<?if(count($orderInfo['childOrder'])) {echo date('Y-m-d',strtotime((string)$orderInfo['childOrder'][0]->UUendtime)+86400);} else echo date('Y-m-d',strtotime((string)$orderInfo['mainOrder'][0]->UUendtime)+86400);?></td>
			<?else:?>
			<td><?=$orderInfo['mainOrder']->UUbegintime?> 至 <?if(count($orderInfo['childOrder'])) {echo (string)$orderInfo['childOrder'][0]->UUendtime;} else echo $orderInfo['mainOrder']->UUendtime ;?></td>
			<?endif;?>
            <?if($orderInfo['mainOrder']->UUctime=='0000-00-00 00:00:00'):?>
            <th>完成时间：</th>
            <td><?=$orderInfo['mainOrder']->UUdtime!="0000-00-00 00:00:00"?$orderInfo['mainOrder']->UUdtime:"未完成"?></td>
            <?else:?>
            <th>取消时间：</th>
            <td><?=$orderInfo['mainOrder']->UUctime?></td>
            <?endif;?>
        </tr>
        <tr>    
            <th>取票人：</th>
            <td><?=$orderInfo['mainOrder']->UUordername?></td>
            <th>取票人手机：</th>
            <td><?=$orderInfo['mainOrder']->UUordertel?></td>
            <th>支付方式：</th>
            <td ><?=$payMode?></td>
        </tr>
        <?php if((int)$orderInfo['mainOrder']->UUlid==10253):?>
            <?php $json = json_decode((string)$orderInfo['mainOrder']->UUseries, true);?>
            <!--轮渡产品-->
            <tr>
                <th>开船时间</th>
                <td colspan="5"><?=$json[1]?></td>
            </tr>
        <?php endif;?>
		<?=$additional_h;// 演出类和轮渡产品附加座位信息?>
        <tr>    
            <?
            if($_GET['from']=='sale' && $saleid)
                echo '<th>分销商：</th>';
            else/*if($_GET['from']=='buy')*/
                echo '<th>供应商：</th>';
            ?>
            <td><?=$dname_one?></td>
            <th>取票地址：</th>
            <td colspan="3"><?=$orderInfo['mainOrder']->UUgetaddr?></td>
        </tr>
        <tr>
            <th>短信发送次数：</th>
            <td><?=$sendSmsNumber?></td>
            <th>订单备注：</th>
            <td colspan="3"><?=(string)$orderInfo['mainOrder']->UUmemo?></td>
        </tr>
        <?if($orderInfo['mainOrder']->UUmid==$memberID || in_array($memberID,$_aids) ||$orderInfo['mainOrder']->UUaid==$memberID ||$_SESSION['dtype']==9 ||$_SESSION['dtype']==6){
        //只有购买者和管理员能查看凭证号
        // if($orderInfo['mainOrder']->UUmid==$memberID || $_SESSION['dtype']==9){
        ?>
		
        <tr>
            <th>凭证号：</th>
            <td  id="getCode" class="setheight_a"><?=$voucher;?></td>
			<th>身份证：</th>
            <td colspan="3">
                <?if(count($tourists)): foreach($tourists as $idcard=>$tourist) echo $tourist.':'.$idcard,'<br/>';?>
				<?else:?>
				<?=$orderInfo['mainOrder']->UUpersonid!=0?$orderInfo['mainOrder']->UUpersonid:'用户没有输入身份证号码';?>
				<?endif;?>
			</td>
        </tr>
            <?php if((int)$orderInfo['mainOrder']->UUonsale==1){?>
                <?php
                $orderid = (int)$orderInfo["mainOrder"]->UUordernum;
                $sql = "select d.id,eMoney,coupon_name from pft_onsale_record r
                    left join pft_member_coupon d on r.ordernum=d.ordernum
                    left join pft_coupons f on d.coupon_id=f.id
                    where r.ordernum='$orderid' limit 1";
//                echo $sql;exit;
                $GLOBALS['le']->query($sql);
                $eMoney = $GLOBALS['le']->fetch_assoc();
                if($eMoney['id']){?>
                <tr>
                    <th>优惠券ID</th>
                    <td><?=$eMoney['id']?></td>
                    <th>优惠券名称</th>
                    <td><?=$eMoney['coupon_name']?></td>
                    <th>金额</th>
                    <td><?=$eMoney['eMoney']/100?></td>
                </tr>
                <?}}?>
        <?}?>    
        <?if($ass_station){?>
		<tr>
			<th>集合地点</th>
			<td colspan="5">
                <?=$ass_station[(int)$orderInfo['mainOrder']->UUassembly]?>
            </td>
		</tr>
		<?}?>
        <?php if($_aids && $_SESSION['memberID']==1):?>

        <tr>
            <th>供应关系：</th>
            <td colspan="5">
                <?php
                /*
                if (!empty($appendInfo['aids_money'])) {
                    $aids_money = array_reverse(unserialize($appendInfo['aids_money']));
                    // print_r($aids_money);
                    foreach ($aids_money as $row) {
                        $pt = $row[1]==1? '余额':'授信';
                        $ac = $row[2] == 0 ? '<span>(-)</span>':'(+)';
                        echo $dname[$row[0]] . '('.$pt . $ac.')>>' ;
                    }
                }
                */
                ?>
            <?php echo $dname[(string)$orderInfo['mainOrder']->UUmid];
			//print_r($aids_money);
			?>
            </td>
        </tr>
        <?endif;?>
    </table>
<?

?>
    <table>
        <caption><?=$title_sub?></caption>
        <?php if($nums = count($orders)):?>
        <tbody>
        <?foreach($orders as $key=> $row):?>
        <tr data-oid="<?=$row->UUordernum?>">
            <?if($orderInfo['mainOrder']->UUp_type=='C'):?>
            <th><?=(string)$row->UUbegintime?></th>
			<?else:?>
			<th>产品名称：</th>
			<?endif;?>
            <td><?=$row->UUltitle.$row->UUttitle?>-<?=OrderRecord::$UUstatusT[(string)$row->UUstatus]?>
            <?if($row->UUsellid==7251){
                echo "[$row->UUordernum]";
            }?>
            </td>
            <?php if($_GET['type']!=='F'):?>
            <th style="width:80px;">票价：</th>
            <td style="width:80px;"><?=(string)$row->UUtprice/100?></td>
            <?php endif;?>
            <th style="width:80px;">门票数：</th>
            <td style="width:80px;"><?=$row->UUtnum?></td>
            <td style="width:120px;">
            <?if($udata[(string)$row->UUordernum]):?>
                <button class="recordBtn" onclick="show_m(<?=(string)$row->UUordernum?>);">修改记录</button>
            <?endif;?>
            <?if($_GET['from']=='buy'):?>
                <a class="aaBtn" target="_blank" href="http://www.12301.cc/productOrder.html?pid=<?=$row->UUpid?>&aid=<?=$row->UUsellid?>">再次购买</a>
            <?endif;?>
                <?//else:?>
           </td>
        </tr>
        <?endforeach;?>
        </tbody>
        <?php endif;?>
    </table>

    <?if(count($orderInfo['packOrder'])){?>
    <table>
        <caption>套票产品</caption>
        <?foreach($orderInfo['packOrder'] as $row){?>
        <tr>    
            <th>产品名称：</th>
            <td><?=$row->UUltitle?><?=$row->UUttitle?></td>
            <th>门票数：</th>
            <td>
                <?=$row->UUtnum?>
            </td>
            <th>使用情况:</th>
            <td><?=OrderRecord::$UUstatusT[(string)$row->UUstatus]?></td>
        </tr>
        <?}?>
    </table>
    <?}?>
    
    <?
    if((string)$orderInfo['mainOrder']->UUp_type=='F'){
            $udata = array_reverse($udata);
    }
    foreach($udata as $key=> $row):?>
    <table class="u_info" style="display:none;" data=<?=$row['orderid']?>>
        <caption>修改信息</caption>
        <tr>    
            <th>修改前人数：</th>
            <td><?=$row['pre_num']?></td>
            <th>修改后人数：</th>
            <td><?=$row['done_num']?></td>
            <th>修改时间:</th>
            <td><?=$row['rectime']?></td>
        </tr>
    </table>
    <?endforeach;?>    
</div>
<script src="js/ui/PopWindow.js" type="text/javascript"></script>
<script src="js/Calendar.js" type="text/javascript"></script>
<script>
$(function(){
    $(".getCode").click(function(){
        $.ajax({
            "url":"call/handle.php?from=orderView&act=getCode&ordernum="+$("#ordernum").val(),
            "dataType":"json",
            "success":function(json){
                $("#getCode").html(json.msg);
                $("#getCode").css({"font-weight":"bold","color":"#FF0000"});
            }
        })
    })
});
function show_m(orderid){
	$(".u_info").hide().each(function(index,object){
		if($(object).attr("data")==orderid){
			$(object).show();
			return true;
		}
	});
}
</script>
<?include("common/footer.html");?>